USE [BVVD]
GO

/****** Object:  View [dbo].[V_PHANQUYEN]    Script Date: 7/13/2013 4:36:57 AM ******/
DROP VIEW [dbo].[V_PHANQUYEN]
GO

/****** Object:  View [dbo].[V_PHANQUYEN]    Script Date: 7/13/2013 4:36:57 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[V_PHANQUYEN] AS
SELECT DISTINCT 
CASE WHEN C.MANSD IS NULL THEN B.MANSD ELSE C.MANSD END AS MANSD,
CASE WHEN C.MAMN IS NULL THEN A.MAMN ELSE C.MAMN END AS MAMN,
CASE WHEN C.SHOW IS NULL THEN A.SHOW ELSE C.SHOW END AS SHOW,
CASE WHEN C.[ADD] IS NULL THEN C.[ADD] ELSE C.[ADD] END AS [ADD],
CASE WHEN C.EDIT IS NULL THEN A.EDIT ELSE C.EDIT END AS EDIT,
CASE WHEN C.[DELETE] IS NULL THEN A.[DELETE] ELSE C.[DELETE] END AS [DELETE]
 FROM F_NHOM_MENU A
JOIN F_NHOM_NSD B
ON A.MANHOM = B.MANHOM
LEFT JOIN
 F_NSD_MENU C
 ON B.MANSD = C.MANSD



GO


